<?php

namespace App\Http\Controllers;

use App\Models\Adminer\Admins;
use App\Models\Members\Members;
use App\Services\ValidatorService;
use App\Utils\ResUtil;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use App\Utils\DateUtil;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\DB;


class Controller extends BaseController
{
    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    /**
     * --管理后端用户
     * @var
     */
    public static $authAdmin = null;
    public function authAdmin()
    {
        return (new Admins())->currentAdminer();
    }

    /**
     * ---接口错误信息返回
     * @param string $msg
     * @param int $code
     * @param array $data
     * @return array
     */
    public function error($msg = "", $code = 201, $data = []): array
    {
        return [
            'code' => $code,
            'data' => $data,
            'userMsg' => $msg,
            'zTime' => DateUtil::now()
        ];
    }

    /**
     * ---接口成功数据返回
     * @param array $data
     * @param string $msg
     * @param int $code
     * @return array
     */
    public function ok($data = [], $msg = 'SUCCESS', $code = 200): array
    {
        return [
            'code' => $code,
            'data' => $data,
            'userMsg' => $msg,
            'zTime' => DateUtil::now()
        ];
    }
}
